package com.weaver.qfengx.action;

import com.alibaba.fastjson.JSON;
import com.weaver.qfengx.entity.Result;

import java.util.function.Supplier;

public class ActionExec {

    /**
     * 进行异常信息包裹
     * @return
     */
    public static String handleWrapExecption(Supplier<String> exec) {
        try {
            return exec.get();
        } catch (Exception e) {
            e.printStackTrace();
            return JSON.toJSONString(Result.exception(e.getMessage()));
        }
    }

}
